import axios from "axios";

const instance = axios.create({
    baseURL: process.env.VUE_APP_BASE_URL
})

//请求拦截器
instance.interceptors.request.use(req => {
    console.log("正在发送请求...")
    return req
})

//相应拦截器
instance.interceptors.response.use(r => {
    if (r.data.status === '200') {
        console.log("请求成功...")
        return Promise.resolve(r)
    } else {
        console.log("请求失败...")
        return Promise.reject(new Error(r.toString()))
    }
})

export default instance;